/**
 * AggregationRestartException.java
 * ************************** 
 * @date Apr 1, 2011
 * @author Michele Tamburini
 * 
 * **************************
 */
package gossipServices.aggregation;

/**
 * Description:
 * Provides an implementation of the  
 * AggregationRestartExceptionInterface
 * and the instructions to set and get the newEpoch
 * and the remaining cycles.
 *
 */
public class AggregationRestartException extends Exception 
	implements AggregationRestartExceptionInterface{
	
	public static final String STD_MESSAGE = "Aggregation need to be restarted";
	
	private int newEpoch;
	private int remainingCycles;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public AggregationRestartException(String msg, int epoch, int remainingCycles){
		super(msg);
		this.newEpoch = epoch;
		this.remainingCycles = remainingCycles;
	}

	@Override
	public final int getNewEpoch() {
		return newEpoch;
	}

	@Override
	public final int getRemainingCycles() {
		return remainingCycles;
	}
	
	public String toString(){
		String s = new String("\n");
		s += super.toString();
		s += STD_MESSAGE + " \nnewEpoch is: " +newEpoch+" remaining cycles: "+remainingCycles; 
		return s;
	}

}
